package zjh.msg.controller;

import zjh.msg.service.MsgService;
import zjh.msg.service.impl.MsgServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delete")
public class MsgDeleteServlet extends HttpServlet {

    private MsgService msgService = new MsgServiceImpl();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        String idStr = req.getParameter("id");
        Integer id = Integer.parseInt(idStr);
        Integer answer = msgService.delete(id);
        resp.sendRedirect("/list");

    }
}
